package com.ihr360.shared.message;


import com.ihr360.shared.message.fallback.MessageServiceFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * Created by davidwei on 17-6-21.
 */

@FeignClient(name = "ihr360-i18n-provider", fallback = MessageServiceFallback.class)
public interface MessageService {
    @RequestMapping(value = "/message/{locale}/{messageId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    String message(@PathVariable(name = "locale") String locale, @PathVariable(name = "messageId") String messageId);

    @RequestMapping(value = "message/{locale}", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_VALUE)
    List<String> messages(@PathVariable(name = "locale") String locale, @RequestBody String[] messageIds);

    @RequestMapping(value = "message/map/{locale}", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_VALUE)
    Map<String,String> messagesMap(@PathVariable(name = "locale") String locale, @RequestBody String[] messageIds);

    @RequestMapping(value = "message/map/{locale}", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_VALUE)
    Map<String, String> messagesMap(@PathVariable(name = "locale") String locale, @RequestBody Map<String, Object[]> messageMap);


    @RequestMapping(value = "message/map", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_VALUE)
    Map<String, List<String>> messagesMap(@RequestBody Map<String, Object[]> messageMap);

}

